home *** CD-ROM | disk | FTP | other *** search
- # include "Boxdefs.h"
- # include "memory.ex"
-
- login(Channel)
- /*------------------------------------------------------------------------*/
- /* Funktion : Macht einen Logeintrag mit offener Endezeit (??:??) */
- /* Inititalisiert diverse Paramter des entsprechenden */
- /* logischen Kanals. */
- /* Uebergabe: Pointer auf logische Kanalstruktur */
- /* Retour : nichts */
- /*------------------------------------------------------------------------*/
- struct header *Channel;
- {
- file LogChannel;
- unsigned long time_();
- long tell_();
- char ChanStr[80];
- char LgStr[260];
- char DatumUhrzeit[25];
- unsigned char meldung[81];
- int i;
- int neu;
- int chan;
- unsigned char *uc;
- unsigned char *charptr;
- char dummy[256] , *cc;
- char mybbs[20];
-
- uc = Channel->Response;
- uc += 17;
- /* Call holen */
- sprintf(Channel->call,"%s",uc);
- i = 0; /* SSID abschneiden */
- while(isalnum(*(Channel->call + i))) i++;
- *(Channel->call + i) = '\0';
-
- uhrzeitlesen(&DatumUhrzeit); /* Uhrzeit lesen */
-
- neu = 0;
-
- if(isCall(Channel->call))
- {
- _setmem(mybbs,7,0);
- neu = findUser(Channel,&DatumUhrzeit,&mybbs);
-
- if(Channel->SFChannel == 2) clearAmtor(Channel->RS232);
-
- }
-
- if ( ((isCall(Channel->call)==1)&&(isBlack(Channel)==0))
- ||(Channel->Mailbox == 0) || (Channel->SFFlag != Off)
- )
- {
- Channel->ErrorCount = 0;
- uc = Channel->Response;
- uc += 17;
- while(!isspace(*uc)) uc++; /* Call ausblenden */
- while( isspace(*uc)) uc++; /* Spaces ausblenden */
-
- sprintf(LgStr,"%s",uc); /* Via .... */
-
- *(LgStr + strlen(LgStr) -1 ) = '\0'; /* CR loeschen */
-
- if(Channel->actual == 1) /* Wenn angezeigt */
- gotoxy(41,6); /* ausgeben */
-
- sprintf(meldung,"%s",Channel->Response+4);
-
- *(meldung + strlen(meldung) - 1 ) = '\0'; /* Cr loeschen */
-
- uc = meldung;
- charptr = Channel->VRAM + 440;
- for(i=0;i<strlen(meldung);i++) /* Meldung im VRAM */
- *charptr++ = *uc++; /* ausgeben */
-
- if(Channel->actual == 1) /* am Bildschirm ebenso */
- {
- GAttrib = Attrib[1];
- write_(STDOUT,meldung,strlen(meldung)); /* wenn angezeigt */
- GAttrib = Attrib[0];
- }
-
- /* Ident besetzen */
- sprintf(Channel->ident,"%s",Channel->call);
-
- /* Kommandozeile besetzen */
- if(isMBCall(Channel->call) == 0)
- {
- if(Channel->SFChannel != 2)
- sprintf(Channel->KomZeile,"%s\r%s de %s>",Channel->MSGS->BoxMSG21,Channel->ident,Channel->OwnCall);
- else
- sprintf(Channel->KomZeile,"\r%s de %s \r+?",Channel->ident,Channel->OwnCall);
- }
- else
- {
- sprintf(Channel->KomZeile,">\r");
- /*send_tnc(1,Channel,"Y0");*/
- }
-
- if(Channel->SFFlag != Off)
- sprintf(Channel->KomZeile,"%c\r",26);
-
-
- if ((Channel->Mailbox == 1)&&(Channel->SFFlag < SFLog))
- {
- Channel->SOffset = Channel->SBuffer;
-
- if((isMBCall(Channel->call)==0)&&(Channel->PrivStatus != 1)&&(Channel->SFChannel == 1))
- {
- buffering(Channel,"\r");
- buffering(Channel,Channel->MSGS->BoxMSG23);
- buffering(Channel,"\r");
- putout(Channel);
- send_tnc(1,Channel,"D");
- Channel->Mailbox = 0;
- }
- else
- {
- Channel->isMBL = 0;
- if(isMBCall(Channel->call)) buffering(Channel,"[MBL-$]\r");
- else
- {
- buffering(Channel,"\r");
- buffering(Channel,Channel->MSGS->BoxMSG24);
- buffering(Channel," ");
- buffering(Channel,Channel->MSGS->BoxMSG25);
- buffering(Channel," ");
- buffering(Channel,DatumUhrzeit);
- if (neu != 1)
- {
- buffering(Channel,Channel->MSGS->BoxMSG28);
- buffering(Channel," ");
- if(*Channel->UsrName != '\0')
- buffering(Channel,Channel->UsrName);
- buffering(Channel,", ");
- buffering(Channel,Channel->MSGS->BoxMSG29);
- buffering(Channel," ");
- buffering(Channel,Channel->LastLogin);
- buffering(Channel," ");
- buffering(Channel,UTC);
- buffering(Channel,"\r");
- }
- if(strlen(Channel->UsrName) == 0)
- {
- buffering(Channel,Channel->MSGS->BoxMSG38);
- buffering(Channel,"\r");
- }
- if(strlen(mybbs) == 0)
- {
- buffering(Channel,Channel->MSGS->BoxMSG39);
- buffering(Channel,"\r");
- }
-
- if(Channel->SFChannel != 2)
- sprintf(ChanStr,"%sSTART.%s",Prefix->Prefix3,Channel->MSGS->ID);
- else
- sprintf(ChanStr,"%sSTARTAMT.%s",Prefix->Prefix3,Channel->MSGS->ID);
- chan = open_(ChanStr,"R");
- if(chan != -1)
- {
- _setmem(dummy,256,0);
- read_(chan,dummy,255);
- close_(chan);
- cc = dummy;
- while((*cc != '\0') && (*cc != '\032')) cc++;
- *cc = '\0';
- buffering(Channel,dummy);
- buffering(Channel,"\r\r");
- }
- else
- buffering(Channel,"\r");
-
- sprintf(ChanStr,"%s%s.AMT",Prefix->Prefix1,Channel->call);
- LogChannel = open_(ChanStr,"R");
- if(LogChannel != -1)
- {
- buffering(Channel,Channel->MSGS->BoxMSG26);
- buffering(Channel,":\r");
- close_(LogChannel);
- putout(Channel);
- sprintf(Channel->Response,"L %s 1-\r",Channel->call);
- interpre(Channel);
- }
- else
- {
- buffering(Channel,Channel->MSGS->BoxMSG27);
- buffering(Channel,"\r\r");
- }
-
- }
-
- scom(Channel);
- Channel->RecStatus = Off;
- Channel->Import = 0;
- }
- }
-
-
- sprintf(ChanStr,"%sPACK.LOG",Prefix->Prefix3);
- /* Warten bis Log offen */
- while((LogChannel = open_(ChanStr,"A")) == -1);
-
- PosEnd(LogChannel);
-
- Channel->LogPos = tell_(LogChannel) ; /* LogPos merken */
- *(DatumUhrzeit+8) = '\0'; /* Dat-Uhr in zwei strings*/
- *(DatumUhrzeit+14)= '\0'; /* zerteilen */
-
- Channel->Score = 0L;
-
- sprintf(Channel->LogZeile, /* Logzeile machen */
- "%-6s %6s %5s - %5s %s %d %s\r\n",
- Channel->call,
- DatumUhrzeit,
- DatumUhrzeit+9,
- "??:??",
- UTC,
- Channel->Log_Chan,
- LgStr);
-
- write_(LogChannel,
- Channel->LogZeile,
- strlen(Channel->LogZeile)); /* schreiben */
-
- close_(LogChannel); /* schliessen */
-
- Channel->connected = 1; /* Als connected merken */
- show_con();
- SetCursor(Channel);
- Channel->TimeOut = time_(); /* Tiemout triggern */
- _setmem(Channel->comstack,256,0);
-
- if(Channel->SFFlag == SFLog) SFWork(Channel);
- }
- else
- send_tnc(1,Channel,"D");
- }
-
- logout(Channel)
- /*------------------------------------------------------------------------*/
- /* Funktion : Ueberschreibt den vorher gemachten Logeintrag im Log mit */
- /* den gemerkten Daten vom Login, sowie der neuen Uhrzeit */
- /* Weiterhin werden merken ueber Retry/Kontingent/Timeout */
- /* in die Logzeile eingearbeitet */
- /* Uebergabe: Pointer auf logische Kanalstruktur */
- /* Retour : nichts */
- /*------------------------------------------------------------------------*/
- struct header *Channel;
- {
- int LogChannel;
- char ChanStr[80];
- char DatumUhrzeit[25];
- int i;
- char meldung[81];
- unsigned char *uc;
- char CharScore[80];
-
- sprintf(ChanStr,"%sPACK.LOG",Prefix->Prefix3);
- /* Warten bis Log offen */
- while((LogChannel = open_(ChanStr,"A")) == -1);
- {
- uhrzeitlesen(DatumUhrzeit); /* Endezeit */
- *(DatumUhrzeit + 14) = '\0'; /* Datum kappen */
-
- /* in Logzeile bringen */
- _move(5,DatumUhrzeit+9,Channel->LogZeile+26);
-
- sprintf(CharScore,"%6ld",Channel->Score);
- _move(6,CharScore,Channel->LogZeile+ 38);
-
- /* Stelle im Log suchen */
- seek_(LogChannel,Channel->LogPos,0); /* seeken */
-
- write_(LogChannel,
- Channel->LogZeile,
- strlen(Channel->LogZeile)
- ); /* schreiben */
-
- close_(LogChannel); /* schliessen */
-
- _setmem(meldung,40,196); /* meldung mit '_' */
- *(meldung + 40) = '\0'; /* versehen */
-
- uc = Channel->VRAM + 440;
- for(i=0;i<strlen(meldung);i++) /* im VRAM ausgeben */
- *uc++ = ' ';
-
- if(Channel->actual == 1) /* wenn angezeigt dann */
- {
- gotoxy(41,6); /* ausgeben */
- GAttrib = Attrib[1];
- write_(STDOUT,meldung,40); /* ausgeben (Bildschirm) */
- GAttrib = Attrib[0];
- }
-
- Channel->connected = 0; /* Disconnected merken */
- Channel->SendStatus= Off;
- Channel->RecStatus = Off;
- Channel->Mailbox = 1;
- Channel->sysinp = 0;
- Channel->SFPos = 1L;
- Channel->Import = 0;
-
- if(Channel->actual == 1)
- {
- gotoxy(27,1);printf("MAILBOX ");
- }
- CloseAll(Channel);
- }
- show_con();
- Channel->SOffset = Channel->SBuffer;
- }
-
- logread(Channel,ID)
- /*------------------------------------------------------------------------*/
- /* Funktion : Reaktion auf das Box-Kommando 'Log' */
- /* Positioniert 800 Bytes vor das Ende des Logs und liest */
- /* ab dem naechsten LF in Channel->Response ein. */
- /* Uebergabe: Pointer auf logische Kanalstruktur */
- /* Retour : nichts */
- /*------------------------------------------------------------------------*/
- struct header *Channel;
- char ID;
- {
- file LogChannel;
- char ChanStr[80];
- int Anzahl;
-
- if (ID == 'P')
- sprintf(ChanStr,"%sPACK.LOG",Prefix->Prefix3);
- else
- sprintf(ChanStr,"%sAMT.LOG",Prefix->Prefix3);
- /* Warten bis Log offen */
- while((LogChannel = open_(ChanStr,"A")) == -1);
- {
-
- seek_(LogChannel,-800L,2);
-
- Channel->SOffset = Channel->SBuffer; /* Buffer vorbereiten */
- buffering(Channel,"\r\r");
-
- while(get_(LogChannel) != 10); /* hinter LF positionieren*/
-
- /* Rest des Logs lesen */
- Anzahl = read_(LogChannel,Channel->SOffset,1000);
-
- close_(LogChannel); /* schliessen */
-
- Channel->SOffset += Anzahl; /* Endepointer aktual. */
-
- *(Channel->SOffset++) = '\015'; /* Cr anfuegen */
-
- scom(Channel); /* ausgabe anstossen */
- }
- }
-
-
- getIndex(Index,call)
- struct userindex *Index;
- char *call;
- {
- int i,found,IFile;
- struct userindex *USRIDX;
- char dummycall[10], *c, ChanStr[80];
- int Count,Menge;
-
-
- sprintf(dummycall,"%-6.6s",call);
- USRIDX = IndexArray;
- found = 0;
- Menge = 12000;
-
- for(i=0 ; (i < 1000) && (found == 0) ; i++, USRIDX++)
- {
- Menge -= 12;
- if(strncmp(dummycall,IndexArray[i].call,6) == 0)
- {
- sprintf(Index->call,"%-6.6s",IndexArray[i].call);
- Index->pos = IndexArray[i].pos ;
- found = 1;
- if(Menge > 0)
- {
- _move(Menge,&IndexArray[i+1],&IndexArray[i]);
- _setmem(&IndexArray[999],12,0);
- }
- }
- }
-
- if(found == 0)
- {
- sprintf(ChanStr,"%sUSER3.IDX",Prefix->Prefix3);
- IFile = open_(ChanStr,"R");
- if(IFile != -1)
- {
- do
- {
- Menge = read_(IFile,MultiBuff,10200);
- Count = Menge;
- if(Menge >= 12)
- {
- c = MultiBuff;
- while((Count > 0) && (found == 0))
- {
- if(strncmp(c,dummycall,6) == 0)
- {
- found = 1;
- USRIDX = (struct userindex *)c;
- sprintf(Index->call,"%-6.6s",USRIDX->call);
- Index->pos = USRIDX->pos;
- }
- c += 12;
- Count += 12;
- }
- }
- }
- while((found == 0) && (Menge == 10200));
- close_(IFile);
- }
- }
- return(found);
- }
-
-
- putIndex(Index)
- struct userindex *Index;
- {
- _move(11988,&IndexArray[0],&IndexArray[1]);
- sprintf(IndexArray[0].call,"%s",Index->call);
- IndexArray[0].pos = Index->pos;
- }
-
-
- saveIndex(Index,Record)
- struct userindex *Index ;
- struct userrec *Record ;
- {
- int UserFile,User1File;
- char ChanStr[80],ChanStr1[80];
- long tell_();
-
- sprintf(ChanStr,"%sUSER3.IDX",Prefix->Prefix3);
- sprintf(ChanStr1,"%sUSER3.DAT",Prefix->Prefix3);
-
- do
- UserFile = open_(ChanStr,"A");
- while(UserFile == -1);
-
- do
- User1File = open_(ChanStr1,"A");
- while(User1File == -1);
-
- Index->pos = tell_(User1File);
-
- write_(User1File,Record,sizeof(struct userrec));
-
- close_(User1File);
-
-
- write_(UserFile,Index,sizeof(struct userindex));
-
- close_(UserFile);
-
- putIndex(Index);
- }
-
-
- getRecord(Index,Record)
- struct userindex *Index;
- struct userrec *Record;
- {
- int UserFile;
- char ChanStr[80];
-
- sprintf(ChanStr,"%sUSER3.DAT",Prefix->Prefix3);
-
- do
- UserFile = open_(ChanStr,"R");
- while(UserFile == -1);
-
- seek_(UserFile,Index->pos,0);
- read_(UserFile,Record,sizeof(struct userrec));
-
- close_(UserFile);
-
- }
-
-
- putRecord(Index,Record)
- struct userindex *Index;
- struct userrec *Record;
- {
- int UserFile;
- char ChanStr[80];
-
- sprintf(ChanStr,"%sUSER3.DAT",Prefix->Prefix3);
-
- do
- UserFile = open_(ChanStr,"W");
- while(UserFile == -1);
-
- seek_(UserFile,Index->pos,0);
- write_(UserFile,Record,sizeof(struct userrec));
-
- close_(UserFile);
-
- }
-
- int findUser(Channel,DatumUhrzeit,mybbs)
- struct header *Channel;
- char *DatumUhrzeit,*mybbs;
- {
- struct userindex Index;
- struct userrec Record;
- int retval;
- int i;
- char *c;
- char *cc;
-
- if(getIndex(&Index,Channel->call) == 0)
- {
- sprintf(Index.call,"%-6.6s",Channel->call);
- _setmem(&Record,sizeof(struct userrec),0);
- sprintf(Record.LastLogin,"%-14.14s",DatumUhrzeit);
- switch(FirstLang[Channel->Log_Chan])
- {
- case 0:
- case 1: Channel->MSGS = Lang1;
- break;
- case 2: Channel->MSGS = Lang2;
- break;
- case 3: Channel->MSGS = Lang3;
- break;
- case 4: Channel->MSGS = Lang4;
- break;
- case 5: Channel->MSGS = Lang5;
- break;
- case 6: Channel->MSGS = Lang6;
- break;
- }
- sprintf(Record.Language,"%-3.3s",Channel->MSGS->ID);
-
- saveIndex(&Index,&Record);
-
- retval = 1;
-
- }
-
- else
-
- {
- getRecord(&Index,&Record);
-
- sprintf(Channel->LastLogin,"%-14.14s",Record.LastLogin);
-
- sprintf(Record.LastLogin,"%-14.14s",DatumUhrzeit);
-
- putIndex(&Index);
- putRecord(&Index,&Record);
-
- retval = 0;
- }
-
- Channel->MSGS = Lang1;
- for(i=0;i<6;i++)
- {
- switch(i)
- {
- case 0 : if(strncmp(Record.Language,Lang1->ID,3)==0)
- {
- i = 6;
- Channel->MSGS = Lang1;
- }
- break;
- case 1 : if(strncmp(Record.Language,Lang2->ID,3)==0)
- {
- i = 6;
- Channel->MSGS = Lang2;
- }
- break;
- case 2 : if(strncmp(Record.Language,Lang3->ID,3)==0)
- {
- i = 6;
- Channel->MSGS = Lang3;
- }
- break;
- case 3 : if(strncmp(Record.Language,Lang4->ID,3)==0)
- {
- i = 6;
- Channel->MSGS = Lang4;
- }
- break;
- case 4 : if(strncmp(Record.Language,Lang5->ID,3)==0)
- {
- i = 6;
- Channel->MSGS = Lang5;
- }
- break;
- case 5 : if(strncmp(Record.Language,Lang6->ID,3)==0)
- {
- i = 6;
- Channel->MSGS = Lang6;
- }
- break;
- }
- }
-
- sprintf(Channel->UsrName,"%s",Record.Name);
- cc = c = Channel->UsrName;
- *c++ = toupper(*cc++);
- do
- {
- if(isalnum(*(c-1))) *c++ = tolower(*cc++);
- else
- *c++ = toupper(*cc++);
- }
- while(*cc != '\0');
- sprintf(mybbs,Record.MyBBS);
- Channel->PrivStatus = Record.Status;
-
- return(retval);
- }
-
-
- int initUser()
- {
- char ChanStr[80];
- int file1,file2;
-
- sprintf(ChanStr,"%sUSER3.IDX",Prefix->Prefix3);
- file1 = open_(ChanStr,"R");
- if(file1 == -1)
- {
- clrscr();
- printf("USER3.IDX not found\n");
- exit();
- }
-
- sprintf(ChanStr,"%sUSER3.DAT",Prefix->Prefix3);
- file2 = open_(ChanStr,"R");
- if(file2 == -1)
- {
- clrscr();
- printf("USER3.DAT not found\n");
- exit();
- }
-
- close_(file1);
- close_(file2);
-
- _setmem(IndexArray,12000,0);
-
- sprintf(ChanStr,"%sUSERS.BOX",Prefix->Prefix3);
- file1 = open_(ChanStr,"R");
- if(file1 != -1)
- {
- read_(file1,IndexArray,12000);
- close_(file1);
- }
- return(1);
- }
-
- SaveUser()
- {
- int file1;
- char ChanStr[80];
-
- sprintf(ChanStr,"%sUSERS.BOX",Prefix->Prefix3);
- file1 = open_(ChanStr,"W");
- if(file1 == -1)
- file1 = open_(ChanStr,"C");
- if(file1 != -1)
- {
- write_(file1,IndexArray,12000);
- close_(file1);
- }
- }
-
- int updateUSR(Call,Name,MailBox,Status,Lang,priv)
- char *Call,*Name,*MailBox,*Lang;
- int priv;
- int Status;
- {
- struct userindex Index;
- struct userrec Record;
- int retval;
- char tempcall[7];
-
- sprintf(tempcall,"%-6.6s",Call);
-
- retval = 0;
-
- if(getIndex(&Index,Call) == 1)
- {
- retval = 1;
-
- getRecord(&Index,&Record);
-
- if(strncmp(Name," ",6) != 0)
- sprintf(Record.Name,"%s",Name);
-
- if(strncmp(MailBox," ",6) != 0)
- sprintf(Record.MyBBS,"%-6.6s",MailBox);
-
- if(strncmp(Lang," ",3) != 0)
- sprintf(Record.Language,"%-3.3s",Lang);
-
- if(Status != -1) Record.Status = Status;
-
- putRecord(&Index,&Record);
- putIndex(&Index);
-
- }
- else
- {
- if(priv == 1)
- {
- _setmem(&Record,sizeof(struct userrec),0);
- sprintf(Record.LastLogin,"%-14.14s"," ");
- sprintf(Record.Language,"%-3.3s"," ");
- sprintf(Record.MyBBS,"%-6.6s",MailBox);
- Record.Status = Status;
- sprintf(Index.call,"%-6.6s",tempcall);
-
- retval = 1;
- saveIndex(&Index,&Record);
- }
- }
- return(retval);
- }
-
- int readUSRInfo(Call,MailBox,LastLogin,OPName,Status,Lang)
- char *Call,*MailBox,*LastLogin,*OPName,*Lang;
- int *Status;
- {
- struct userindex Index;
- struct userrec Record;
- char tempcall[7];
-
- _setmem(MailBox,7,0);
-
- if(getIndex(&Index,Call) == 1)
- {
-
- getRecord(&Index,&Record);
-
- sprintf(tempcall,"%-6.6s",Record.MyBBS);
- if(strcmp(tempcall,"OwnBBS") != 0)
- sprintf(MailBox,"%s",Record.MyBBS);
-
- sprintf(LastLogin,"%s",Record.LastLogin);
- sprintf(OPName,"%s",Record.Name);
-
- sprintf(Lang,"%-3.3s",Record.Language);
-
- *Status = Record.Status;
-
- putIndex(&Index);
-
- return(1);
- }
- else return(-1);
- }
-